﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using forum_iteration1;
using forum_iteration1.Forum;
using System.Runtime.Remoting.Channels.Tcp;

namespace Client
{
    class Program
    {

        static void Main(string[] args)
        {

            Console.Title = "Remote Client";

            // create and register the remoting channel
            TcpChannel x_channel = new TcpChannel();
            ChannelServices.RegisterChannel(x_channel, false);

            // local member to initialize the remoting system
            //IUser user = (IUser)Activator.GetObject(typeof(forum_iteration1.Forum.IUser), "tcp://localhost:20172/User");
            
            RemotingConfiguration.RegisterActivatedClientType(typeof(User), "tcp://localhost:20172/User");
            
            IUser user = new User("Shai", "password", "shai@mail.com", "123", "Shai", "Cantor");

            if (user == null)
                Console.WriteLine("could not locate server");

            else
            {
                while (true)
                {
                    System.Console.WriteLine("What is your name? (just hit enter to quit)");

                    String strName = Console.ReadLine();

                    if (String.IsNullOrEmpty(strName))
                        break;

                    // Make method call to remote object
                    
                    user.hello(strName);
                    
                }
            }

        }

    }
}
